package cs304.p3.library.framework;

import javax.swing.SwingUtilities;

import cs304.p3.library.domain.Borrower;
import cs304.p3.library.model.DBTableModel.TableType;
import cs304.p3.library.view.BorrowerAccountDialog;
import cs304.p3.library.view.BorrowerDialog;
import cs304.p3.library.view.CheckOutBookDialog;
import cs304.p3.library.view.ClerkDialog;
import cs304.p3.library.view.DBObjectDialog;
import cs304.p3.library.view.DBObjectDialog.DBOActionType;
import cs304.p3.library.view.LibrarianDialog;
import cs304.p3.library.view.LoginDialog;
import cs304.p3.library.view.MainFrame;

// navigation god class.
// use it to get to any other view in our application.
// I had page-like navigation in mind for this 
public class ViewResolver {
	private static final MainFrame mainFrame = new MainFrame();

	// method for each different view; could associate them with text names
	// later to access any view from the main frame

	public static void gotoMainView() {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				mainFrame.setVisible(true);
			}
		});
	}

	public static void gotoLoginView() {
		new LoginDialog(mainFrame, "Switch User");
	}
	
	public static void gotoBorrowerView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Borrower View", TableType.BORROWER, type);
	}

	public static void gotoBorrowerTypeView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Borrower Type View", TableType.BORROWERTYPE, type);
	}
	
	public static void gotoBookView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Book View", TableType.BOOK, type);
	}
	
	public static void gotoHasAuthorView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Has Author View", TableType.HASAUTHOR, type);
	}
	
	public static void gotoHasSubjectView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Has Subject View", TableType.HASSUBJECT, type);
	}
	
	public static void gotoBookCopyView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Book Copy View", TableType.BOOKCOPY, type);
	}
	
	public static void gotoHoldRequestView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Hold Request View", TableType.HOLDREQUEST, type);
	}
	
	public static void gotoBorrowingView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Borrowing View", TableType.BORROWING, type);
	}
	
	public static void gotoFineView(DBOActionType type) {
		new DBObjectDialog(mainFrame, "Fine View", TableType.FINE, type);
	}

	public static void gotoClerkView() {
		new ClerkDialog(mainFrame, "Clerk Transactions");
	}

	public static void gotoLibrarianView() {
		new LibrarianDialog(mainFrame, "Librarian Transactions");
	}
	
	public static void gotoUserBorrowerView(){
		new BorrowerDialog(mainFrame, "Borrower Transactions");
	}
	
	public static void gotoCheckOutBookView(){
		new CheckOutBookDialog(mainFrame, "New Check Out Book");
	}
	
	public static void gotoBorrowerAccountView(Borrower b){
		new BorrowerAccountDialog(mainFrame, "Account Details", b);
	}
}
